package com.sitech.ibnms.c3p.service;

import com.sitech.ibnms.c3p.Application;
import com.sitech.ibnms.c3p.task.notice.ExecutePolicy;
import org.apache.ignite.services.ServiceContext;

import java.util.Map;

/**
 * Created by leo on 16/2/29.
 * 提供给页面，推动环节执行
 */
public class IgniteC3pTaskFlowServiceImpl extends IgniteService implements C3pTaskFlowService {
    private C3pTaskFlowService service;//通过

    @Override//找到spring容器里的
    public void execute(ServiceContext ctx) throws Exception {
        super.execute(ctx);
        service = Application.getBean(C3pTaskFlowService.class);
    }

    @Override
    public int startTask(String c3pTaskId, String userId, String title) {
        return service.startTask(c3pTaskId, userId, title);
    }

    @Override//启动任务，并自带执行策略
    public int startTaskWithExecutePolicies(String c3pTaskId, String userId, String title, Map<Integer, ExecutePolicy> executePolicies) {
        return service.startTaskWithExecutePolicies(c3pTaskId, userId, title, executePolicies);
    }

    @Override//结束任务
    public void terminate(int serialNo, String userId, String title) {
        service.terminate(serialNo, userId, title);
    }

    @Override//启动节点，并自带执行策略(如果任务执行失败，重新执行，或人工节点执行 从该节点开始执行)
    public void startNodeWithExecutePolicies(int taskId, String userId, String title, Map<Integer, ExecutePolicy> executePolicies) {
        service.startNodeWithExecutePolicies(taskId, userId, title, executePolicies);
    }
    @Override
    public Map<String,String> executeShell(Map<String, String> params,Map<String,String> inputVars, Map<String,String> outputVars){
        return service.executeShell(params,inputVars,outputVars);
    }
    @Override
    public Map<String,String> executeSql(Map<String, String> params,Map<String,String> inputVars){
        return service.executeSql(params,inputVars);
    }
}
